//
//  ViewLogin.swift
//  weibo
//
//  Created by 陈经纬 on 16/7/18.
//  Copyright © 2016年 陈经纬. All rights reserved.
//

import UIKit

class ViewLogin: UIView {
    /// 转盘
    @IBOutlet weak var tuntable: UIImageView!
    /// 图标小屋
    @IBOutlet weak var iconImage: UIImageView!
    /// 文字
    @IBOutlet weak var textLable: UILabel!

    @IBOutlet weak var register: UIButton!
    
    @IBOutlet weak var login: UIButton!
    
    class  func visitorView() -> ViewLogin {
        return NSBundle.mainBundle().loadNibNamed("ViewLogin", owner: nil, options: nil).last as! ViewLogin
        
    }
    
    
    /// 设置访客视图上的数据
    /// imageName需要显示的图标
    /// title需要显示的标题
    func setupVisitData(title:String,imageName:String?)  {
        textLable.text = title
        
        guard let name = imageName else{
            SetupAnimation()
            return
        }
        
        tuntable.hidden = true
        iconImage.image = UIImage(named: name)
    }
    
    func SetupAnimation() {
        //新建动画
        let animaton = CABasicAnimation(keyPath: "transform.rotation")
        //动画属性
        animaton.toValue = 2 * M_PI
        animaton.duration = 10
        animaton.repeatCount = MAXFLOAT
        
        animaton.removedOnCompletion = false
        
        tuntable.layer.addAnimation(animaton, forKey: nil)
        
    }
    
}
